/*
============================================================================
FileName	:	XQChatConfiguration.h
Author		:	liyake
Website		:	http://www.liyake.com
Create Data	:	2012-03-08 13:07
Change Data	:	2012-03-08 13:07
Detail		:	The configuration(struct) of xqchat application
============================================================================
*/
#ifndef _XQCHAT_CONFIGURATION_H_
#define _XQCHAT_CONFIGURATION_H_
#include <QApplication>
#include <QXmppConfiguration.h>

namespace XQChat
{
	class CXQChatConfiguration : public QXmppConfiguration
	{
	public:
		enum XQChatClientType		//diffrent client type
		{
			XQChatRenren = 1, ///renren client. website:http://renren.com ,jabber server:take.xiaonei.com
			XQChatGTalk,    ///google talk client. website:http://mail.google.com
			XQChatMSN     ///MSN client. website:http://www.msn.com
		};

		struct XQChatClientConfig
		{
			QString qsName;
			QString qsDomain;
			XQChatClientType typeOfClient;
			QString qsIcon;
			QList<QString> listDomains;
			int iPort;
			QString qsDefaultHeader;

			XQChatClientConfig()
			{
				iPort = 5222;		//default port
				typeOfClient = XQChatRenren;	//default client type
			}
		};

	public:
		CXQChatConfiguration(const QString& jid,const QString& password);
		CXQChatConfiguration(const CXQChatConfiguration& config);
		CXQChatConfiguration();
		~CXQChatConfiguration(void);

		//load clients config file, default path:"./data/config/ClientConfig.xml"
		static bool loadClientConfig(
			QString qsFileName = qApp->applicationDirPath()+"/data/config/ClientConfig.xml");

	public:
		void setJid(const QString &jid);
		XQChatClientType getClientType() const {return m_typeOfClient;}
		QString getClientTypeStr() const;
		QString getIconPath() const {return m_qsIcon;}
		QString getDefaultHeader() const {return m_qsDefaultHeader;}

	protected:
		//reset the client configuration
		void resetClientConfig(const CXQChatConfiguration::XQChatClientConfig& config);

	protected:
		static QMap<CXQChatConfiguration::XQChatClientType,CXQChatConfiguration::XQChatClientConfig> m_mapClientConfig;
		XQChatClientType m_typeOfClient;
		QString m_qsIcon;			//icon file path
		QString m_qsDefaultHeader;	//default header.
	};
}

#endif	//_XQCHAT_CONFIGURATION_H_